package com.jjr.action;

import tool.TimeTool;

import com.base.bean.*;
import com.jjr.service.*;
import com.jjr.bean.*;

public class JUserAction extends BaseAction {
	private String name,phone,idcard,city,province,area,bankNo,company;
	private String cityId,provinceId,areaId;
	private Integer bankType,id;
	
//	private String openId;
	
	private JingJiRenService js;

	public JUserAction() {
		js = JingJiRenService.getInstance();
	}
	
	
	public static void main(String[] args){
		JUserAction a = new JUserAction();
		a.id=1;
		a.name="bob2";
		a.phone="15982079517";
		a.city="成都2";
		a.area="成华区2";
		a.province="四川";
		a.idcard="370724199403116619";
		
		a.mergeJUser();
		System.out.println(a.result.getTip());
		
	}
	
	/**
	 * 包含了新增客户和修改客户
	 * id>0 则为修改
	 * @return
	 */
	public String mergeJUser(){
		this.id=(this.id==null?0:this.id);
		this.openId = (this.openId==null?"":this.openId);
		
		if(this.openId.equals("")){
			this.result.setTip("未识别到登录用户，请重新登录");
			this.result.setState(-1);
			return SUCCESS;
		}
		
		this.name  = (this.name==null?"":this.name.replaceAll("\\s*", ""));
		this.phone  = (this.phone==null?"":this.phone.replaceAll("\\s*", ""));
		this.idcard  = (this.idcard==null?"":this.idcard.replaceAll("\\s*", ""));
		this.bankNo  = (this.bankNo==null?"":this.bankNo.replaceAll("\\s*", ""));
		this.company  = (this.company==null?"":this.company.replaceAll("\\s*", ""));
		
		this.city=(this.city==null?"":this.city);
		this.area=(this.area==null?"":this.area);
		this.province=(this.province==null?"":this.province);
		
		this.areaId = (this.areaId == null ? "" : this.areaId);
		this.cityId = (this.cityId == null ? "" : this.cityId);
		this.provinceId = (this.provinceId == null ? "" : this.provinceId);
		
		JUser user = new JUser();
		user.setOpenId(this.openId);
		user.setId(this.id);
		user.setName(name);
		user.setArea(this.area);
		user.setCity(this.city);
		user.setProvince(this.province);
		user.setPhone(this.phone);
		user.setIdCard(this.idcard);
		user.setBankNo(this.bankNo);
		user.setCompany(this.company);
		user.setBankType(this.bankType);
		
		this.result=js.mergeJUser(user);
		return SUCCESS;
		
		
	}
	
	@Override
	public String execute(){
		return SUCCESS;
	}


	public String getName() {
		return name;
	}



	public void setName(String name) {
		this.name = name;
	}



	public String getPhone() {
		return phone;
	}



	public void setPhone(String phone) {
		this.phone = phone;
	}



	public String getIdcard() {
		return idcard;
	}



	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}



	public String getCity() {
		return city;
	}



	public void setCity(String city) {
		this.city = city;
	}



	public String getProvince() {
		return province;
	}



	public void setProvince(String province) {
		this.province = province;
	}



	public String getArea() {
		return area;
	}



	public void setArea(String area) {
		this.area = area;
	}



	public String getBankNo() {
		return bankNo;
	}



	public void setBankNo(String bankNo) {
		this.bankNo = bankNo;
	}



	public String getCompany() {
		return company;
	}



	public void setCompany(String company) {
		this.company = company;
	}



	public Integer getBankType() {
		return bankType;
	}



	public void setBankType(Integer bankType) {
		this.bankType = bankType;
	}



	public Integer getId() {
		return id;
	}



	public void setId(Integer id) {
		this.id = id;
	}


	public String getCityId() {
		return cityId;
	}


	public void setCityId(String cityId) {
		this.cityId = cityId;
	}


	public String getProvinceId() {
		return provinceId;
	}


	public void setProvinceId(String provinceId) {
		this.provinceId = provinceId;
	}


	public String getAreaId() {
		return areaId;
	}


	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}

	

	
	


}
